home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 7 / Amiga Format AFCD07 (Dec 1996, Issue 91).iso / serious / shareware / programming / aros / intuition / makeclass.c < prev    next >
C/C++ Source or Header  |  1996-09-12  |  4KB  |  128 lines

  1. /*
  2.     (C) 1995-96 AROS - The Amiga Replacement OS
  3.     $Id: makeclass.c,v 1.1 1996/08/28 17:55:35 digulla Exp $
  4.     $Log: makeclass.c,v $
  5.     Revision 1.1  1996/08/28 17:55:35  digulla
  6.     Proportional gadgets
  7.     BOOPSI
  8.  
  9.  
  10.     Desc:
  11.     Lang: english
  12. */
  13. #include <exec/memory.h>
  14. #include <clib/exec_protos.h>
  15. #include "intuition_intern.h"
  16.  
  17. /*****************************************************************************
  18.  
  19.     NAME */
  20.     #include <intuition/classes.h>
  21.     #include <clib/intuition_protos.h>
  22.  
  23.     __AROS_LH5(struct IClass *, MakeClass,
  24.  
  25. /*  SYNOPSIS */
  26.     __AROS_LHA(UBYTE         *, classID, A0),
  27.     __AROS_LHA(UBYTE         *, superClassID, A1),
  28.     __AROS_LHA(struct IClass *, superClassPtr, A2),
  29.     __AROS_LHA(unsigned long  , instanceSize, D0),
  30.     __AROS_LHA(unsigned long  , flags, D1),
  31.  
  32. /*  LOCATION */
  33.     struct IntuitionBase *, IntuitionBase, 113, Intuition)
  34.  
  35. /*  FUNCTION
  36.     Only for class implementators.
  37.  
  38.     This function creates a new public BOOPSI class. The SuperClass
  39.     should be another BOOPSI class; all BOOPSI classes are subclasses
  40.     of the ROOTCLASS.
  41.  
  42.     SuperClasses can by private or publiec. You can specify aname/ID
  43.     for the class if you want it to become a public class. For public
  44.     classes, you must call AddClass() afterwards to make it public
  45.     accessible.
  46.  
  47.     The returnvalue contains a pointer to the IClass structure of your
  48.     class. You must specify your dispatcher in cl_Dispatcher. You can
  49.     also store shared data in cl_UserData.
  50.  
  51.     To get rid of the class, you must call FreeClass().
  52.  
  53.     INPUTS
  54.     classID - NULL for private classes otherwise the name/ID of the
  55.         public class.
  56.     superClassID - Name/ID of a public SuperClass. NULL is you don't
  57.         want to use a public SuperClass or if you have the pointer
  58.         your SuperClass.
  59.     superClassPtr - Pointer to the SuperClass. If this is non-NULL,
  60.         then superClassID is ignored.
  61.     instanceSize - The amount of memory which your objects need (in
  62.         addition to the memory which is needed by the SuperClass(es))
  63.     flags - For future extensions. To maintain comaptibility, use 0
  64.         for now.
  65.  
  66.     RESULT
  67.     Pointer to the new class or NULL if
  68.     - There wasn't enough memory
  69.     - The superclass couldn't be found
  70.     - There already is a class with the same name/ID.
  71.  
  72.     NOTES
  73.     No copy is made of classID. So make sure the lifetime of the contents
  74.     of classID is at least the same as the lifetime of the class itself.
  75.  
  76.     EXAMPLE
  77.  
  78.     BUGS
  79.  
  80.     SEE ALSO
  81.  
  82.     INTERNALS
  83.  
  84.     HISTORY
  85.     29-10-95    digulla automatically created from
  86.                 intuition_lib.fd and clib/intuition_protos.h
  87.  
  88. *****************************************************************************/
  89. {
  90.     __AROS_FUNC_INIT
  91.     __AROS_BASE_EXT_DECL(struct IntuitionBase *,IntuitionBase)
  92.     Class * iclass;
  93.  
  94.     /* trust the user ;-) */
  95.     if (!superClassID && !superClassPtr)
  96.     return (NULL);
  97.  
  98.     /* Does this class already exist ? */
  99.     if (FindName (PublicClassList, classID))
  100.     return (NULL);
  101.  
  102.     /* Has the user specified a classPtr ? */
  103.     if (!superClassPtr)
  104.     {
  105.     /* Search for the class ... */
  106.     if (!(superClassPtr = (Class *)FindName (PublicClassList, superClassID)) )
  107.         return (NULL);  /* nothing found */
  108.     }
  109.  
  110.     /* Get some memory */
  111.     if ((iclass = (Class *) AllocMem (sizeof (Class), MEMF_PUBLIC|MEMF_CLEAR)))
  112.     {
  113.     /* Felder init */
  114.     iclass->cl_Super      = superClassPtr;
  115.     iclass->cl_ID          = classID;
  116.     iclass->cl_InstOffset = superClassPtr->cl_InstOffset +
  117.                 superClassPtr->cl_InstSize;
  118.     iclass->cl_InstSize   = instanceSize;
  119.     iclass->cl_Flags      = flags;
  120.  
  121.     /* SuperClass is used one more time now */
  122.     superClassPtr->cl_SubclassCount ++;
  123.     }
  124.  
  125.     return (iclass);
  126.     __AROS_FUNC_EXIT
  127. } /* MakeClass */
  128.